<?php
if($this->ma == 1){
    echo '<script language="javascript" type="text/javascript">alert("发票保存成功！"); </script>';
}else if($this->ma == 2){
    echo '<script language="javascript" type="text/javascript">alert("发票收货人信息和包裹物品信息不能为空！"); </script>';
}else if($this->ma == 3 ){
    echo '<script language="javascript" type="text/javascript">window.open("/admini/managewaybill/preview/id/'.$this->billall->id.'/ma/'.$this->ma.'","_blank"); </script>';
    $this->ma = 5;
}else if($this->ma == 4){
    echo '<script language="javascript" type="text/javascript">location.href="/admini/managewaybill/preview/id/'.$this->billall->id.'"; </script>';
}else if($this->ma == 6){
    echo '<script language="javascript" type="text/javascript">window.open("http://localhost:5997/Print.ashx?type=3&wayId='.$this->billall->id.'","_blank"); </script>';
}
?>
<form method="post" action="/admini/managewaybill/invoice/id/<?php echo $this->billall->id;?>" id="formshipment">
    	<div class="houtaiweizhi">
        	<label>您的位置：</label><p><a href="/admini/managewaybill/index">国际运单列表</a><span>|</span><a href="/admini/manageuser/userdetail/id/<?php echo $this->billall->userId?>" target="_blank"><?php echo $this->billall->user->storeno;?>的国际运单</a><span>|</span>编辑发票</p>
        </div>
    	<div class="fapiaoleft">
            <div class="fptable">
              <?php if($this->ma != 1 && $this->ma != 5){ ?>
              <table>
                    <tr class="fp1">
                        <td class="bjfp" colspan="10"><h1>COMMERCIAL INVOICE</h1></td>
                    </tr>
                    <tr class="fp2">
                      <td class="rightline" colspan="3"><h2>INTERNATIONAL AIR WAYBILL NO.</h2></td>
                        <td colspan="7"><input class="inputwu w150" name="awn1" id="awn1" type="text" value="<?php echo $this->invoiceall?$this->invoiceall->waybillno:"";?>"/></td>
                    </tr>
                    <tr class="fp3">
                      <td class="rightline" colspan="3"><h2>DATE OF EXPORTATION</h2></td>
                      <td class="rightline" colspan="2"><input class="inputwu w150" type="text" id="od1" name="od1" value="<?php echo $this->invoiceall?$this->invoiceall->orderdate:date('Y-m-d');?>" /></td>
                      <td class="rightline" colspan="3"><h2 class="pleft">INVOICE NO.</h2></td>
                        <td colspan="2"><input class="inputwu w150" type="text" id="inv1" name="inv1" value="<?php echo $this->invoiceall?$this->invoiceall->invoiceno:$this->billall->user->storeno."-".$this->billall->BillNo;?>"/></td>
                    </tr>
		    <tr class="fp4">
                        <td class="rightline fpw400" colspan="5">
                        	<h2>FROM (Shipper)</h2>
                            <div class="fpdizhi">
                                <p>No.3 Langshan 2nd Street,Area of Hi-Tech Industrial Zone<br>Nanshan District, SHENZHEN<br>GUANGDONG CHINA</p>
                                <p>Tel:<span>0755-88605979</span></p>
                                <p>Contact:<span>UUCH</span></p>
                            </div>
                        </td>
                        <td class="fpw400" colspan="5">
                        	<h2 class="pleft">TO (Receiver)</h2>
                            <div class="fpdizhi">
                            	<textarea class="textareawu" id="rad1" name="rad1" ><?php echo $this->invoiceall?$this->invoiceall->address:$this->billall->conAdd;?></textarea>
                            	<ul>
                                    <li><label>Zip code:</label><input class="inputwu w300" type="text" id="zipcode" name="zipcode" value="<?php echo $this->invoiceall?$this->invoiceall->zipcode:$this->billall->conPostCode;?>" /></li>
                                    <li><label>Tel:</label><input class="inputwu w300" type="text" id="rp1" name="rp1" value="<?php echo $this->invoiceall?$this->invoiceall->tel:$this->billall->conTel;?>" /></li>
                                    <li><label>Contact:</label><input class="inputwu w300" type="text" id="ncp1" name="ncp1" value="<?php echo $this->invoiceall?$this->invoiceall->attn:$this->billall->consignee;?>" /></li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                    <tr class="fp5">
                        <td class="rightline" colspan="5">
                        	<h2>COUNTRY OF EXPORT</h2>
                            <h3>China </h3>
                        </td>
                        <td colspan="5">
                        	<h2 class="pleft">COUNTRY OF ULTIMATE DESTINATION</h2>
                            <input class="inputwu w350" type="text" id="country" name="country" value="<?php echo $this->invoiceall?$this->invoiceall->country:$this->billall->UserCity->ename."(".$this->billall->UserCity->name.")";?>" />
                        </td>
                    </tr>
                    <tr class="fp6">
                        <td class="rightline" colspan="5">
                        	<h2>REASON FOR EXPORT (e.g. personal gift, return for repair)</h2>
                            <input class="inputwu w350" type="text" id="reason" name="reason" value="<?php echo $this->invoiceall?$this->invoiceall->reason:"";?>" />
                        </td>
                        <td colspan="5">
                        	<h2 class="pleft">WEIGHT</h2>
                            <input class="inputwu w350" type="text" id="weight" name="weight" value="<?php echo $this->invoiceall?($this->invoiceall->weight=="0.00"?"":$this->invoiceall->weight."kg"):"";?>" />
                        </td>
                    </tr>
                    <tr class="fp7">
                        <td class="rightline"><h2>NO. OF<br />
                        PKGS</h2></td>
                      <td class="rightline" colspan="3"><h2>DESCRIPTION OF GOODS</h2></td>
                      <td class="rightline"><h2>HS CODE</h2></td>
                      <td class="rightline" colspan="2"><h2>QTY</h2></td>
                      <td class="rightline" colspan="2"><h2>UNIT VALUE<br />
                        USD</h2></td>
                        <td><h2>TOTAL<br />
                        VALUE</h2></td>
                    </tr>
                    <?php if($this->invoicedetail){
                            foreach($this->invoicedetail as $key => $valItem){ ?>
				<tr id="tr<?php echo $key+1;?>"><input type="hidden" id="did<?php echo $key+1;?>" name="did<?php echo $key+1;?>" value="<?php echo $valItem->id;?>" />
                                    <td align="center"><input class="inputwu w30" type="text" id="pkgs<?php echo $key+1;?>" name="pkgs<?php echo $key+1;?>" value="<?php echo $valItem->pkgs>0?$valItem->pkgs:""; ?>" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                    <td colspan="3" align="center"><input class="inputwu w200" type="text" name="inna<?php echo $key + 1; ?>" id="inna<?php echo $key + 1; ?>" value="<?php echo $valItem->description; ?>" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                    <td align="center"><input class="inputwu w80" type="text" name="inhs<?php echo $key + 1; ?>" id="inhs<?php echo $key + 1; ?>" value="<?php echo $valItem->hscode; ?>" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                    <td colspan="2" align="center"><input class="inputwu w30" type="text" name="insu<?php echo $key + 1; ?>" id="insu<?php echo $key + 1; ?>" value="<?php echo $valItem->num; ?>" onchange="javascript:ckprto(<?php echo $key + 1; ?>)" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                    <td colspan="2" align="center"><input class="inputwu w80" type="text" name="inpr<?php echo $key + 1; ?>" id="inpr<?php echo $key + 1; ?>" value="<?php echo $valItem->price; ?>" onchange="javascript:ckprto(<?php echo $key + 1; ?>)" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                    <td align="center"><input class="inputwu w80" type="text" name="into<?php echo $key + 1; ?>" id="into<?php echo $key + 1; ?>" value="<?php echo $valItem->total; ?>" onchange="javascript:ckprto2(<?php echo $key + 1; ?>)" onblur="javascript:prin(<?php echo $key+1;?>)"/></td>
                                </tr>
                    <?php }} 
			$count = $this->invoicedetail?count($this->invoicedetail):0;
			for ($i = $count+1; $i < 6; $i++) {
                    ?>
                        <tr class="fpxuxian" id="tr<?php echo $i;?>">
                            <td align="center"><input class="inputwu w30" type="text" id="pkgs<?php echo $i;?>" name="pkgs<?php echo $i;?>" value="" onblur="javascript:prin(<?php echo $i;?>)"/></td>
                            <td colspan="3" align="center"><input class="inputwu w200" type="text" name="inna<?php echo $i; ?>" id="inna<?php echo $i; ?>" value="" onblur="javascript:prin(<?php echo $i;?>)"/></td>
                            <td align="center"><input class="inputwu w80" type="text" name="inhs<?php echo $i; ?>" id="inhs<?php echo $i; ?>" value="" onblur="javascript:prin(<?php echo $i;?>)" /></td>
                            <td colspan="2" align="center"><input class="inputwu w30" type="text" name="insu<?php echo $i; ?>" id="insu<?php echo $i; ?>" value="" onchange="javascript:ckprto(<?php echo $i; ?>)" onblur="javascript:prin(<?php echo $i;?>)"/></td>
                            <td colspan="2" align="center"><input class="inputwu w80" type="text" name="inpr<?php echo $i; ?>" id="inpr<?php echo $i; ?>" value="" onchange="javascript:ckprto(<?php echo $i; ?>)" onblur="javascript:prin(<?php echo $i;?>)"/></td>
                            <td align="center"><input class="inputwu w80" type="text" name="into<?php echo $i; ?>" id="into<?php echo $i; ?>" value="" onchange="javascript:ckprto2(<?php echo $i; ?>)" onblur="javascript:prin(<?php echo $i;?>)"/></td>
                        </tr>
                    <?php }?>
                    <tr class="fp8">
                        <td colspan="9"><input type="hidden" name="num" id="num" value="5" /></td>
                        <td><h2>1TOTAL INVOICE<br />
                        VALUE</h2></td>
                    </tr>
                    <tr class="fp9">
                        <td colspan="9">&nbsp;</td>
                        <td class="dyg_jg"><input class="inputwu w80" style="text-align: right;width: 50px;" type="text" name="ztotal" id="ztotal" value="<?php echo $this->invoiceall?$this->invoiceall->total:0;?>" /><span style="color:#C00;">(USD)</span></td>
                    </tr>
                    <tr class="fp10">
                        <td colspan="10"><h2>I DECLARE ALL THE INFORMATION CONTAINED IN THE INVOICE TO BE TRUE AND CORRECT.</h2></td>
                    </tr>
                    <tr>
                        <td class="dyg_qm" colspan="4"><h2>SIGNATURE OF SHIPPER / EXPORTER</h2></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td align="center"><h2>DATE</h2></td>
                    </tr>
                    <tr>
                        <td width="70" class="dyg_jg">UUCH</td>
                        <td width="80"></td>
                        <td width="80"></td>
                        <td width="80"></td>
                        <td width="110"></td>
                        <td width="60"></td>
                        <td width="60"></td>
                        <td width="60"></td>
                        <td width="80"></td>
                        <td class="dyg_jg" align="center"><?php echo $this->invoiceall?$this->invoiceall->orderdate:date('Y-m-d');?></td>
                    </tr>
              </table>
              <?php }else{?>
                    <table>
                        <tr class="fp1">
                                <td class="bjfp" colspan="10"><h1>COMMERCIAL INVOICE</h1></td>
                            </tr>
                            <tr class="fp2">
                                <td class="rightline" colspan="3"><h2>INTERNATIONAL AIR WAYBILL NO.</h2></td>
                                <td colspan="7"><?php echo $this->invoiceall ? $this->invoiceall->waybillno : ""; ?></td>
                            </tr>
                            <tr class="fp3">
                                <td class="rightline" colspan="3"><h2>DATE OF EXPORTATION</h2></td>
                                <td class="rightline" colspan="2"><h3><?php echo $this->invoiceall ? $this->invoiceall->orderdate : date('Y-m-d'); ?></h3></td>
                                <td class="rightline" colspan="3"><h2 class="pleft">INVOICE NO.</h2></td>
                                <td colspan="2"><h3><?php echo $this->invoiceall ? $this->invoiceall->invoiceno : $this->billall->user->storeno . "-" . date('Ymd'); ?></h3></td>
                            </tr>
                            <tr class="fp4">
                                <td class="rightline fpw400" colspan="5">
                                    <h2>FROM (Shipper)</h2>
                                    <div class="fpdizhi">
                                        <p>No.3 Langshan 2nd Street,Area of Hi-Tech Industrial Zone<br>Nanshan District, SHENZHEN<br>GUANGDONG CHINA</p>
                                        <p>Tel:<span>0755-88605979</span></p>
                                        <p>Contact:<span>UUCH</span></p>
                                    </div>
                                </td>
                                <td class="fpw400" colspan="5">
                                    <h2 class="pleft">TO (Receiver)</h2>
                                    <div class="fpdizhi">
                                        <h3><?php echo $this->invoiceall ? $this->invoiceall->address : $this->billall->conAdd; ?></h3>
                                        <ul>
                                            <li><label>Zip code:</label><span><?php echo $this->invoiceall ? $this->invoiceall->zipcode : $this->billall->conPostCode; ?></span></li>
                                            <li><label>Tel:</label><span><?php echo $this->invoiceall ? $this->invoiceall->tel : $this->billall->conTel; ?></span></li>
                                            <li><label>Contact:</label><span><?php echo $this->invoiceall ? $this->invoiceall->attn : $this->billall->consignee; ?></span></li>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr class="fp5">
                                <td class="rightline" colspan="5">
                                    <h2>COUNTRY OF EXPORT</h2>
                                    <h3>China </h3>
                                </td>
                                <td colspan="5">
                                    <h2 class="pleft">COUNTRY OF ULTIMATE DESTINATION</h2>
                                    <h3><?php echo $this->invoiceall ? $this->invoiceall->country : $this->billall->UserCity->ename . "(" . $this->billall->UserCity->name . ")"; ?></h3>
                                </td>
                            </tr>
                            <tr class="fp6">
                                <td class="rightline" colspan="5">
                                    <h2>REASON FOR EXPORT (e.g. personal gift, return for repair)</h2>
                                    <h3><?php echo $this->invoiceall ? $this->invoiceall->reason : ""; ?></h3>
                                </td>
                                <td colspan="5">
                                    <h2 class="pleft">WEIGHT</h2>
                                    <h3><?php echo $this->invoiceall?($this->invoiceall->weight=="0.00"?"":$this->invoiceall->weight."kg"):"";?></h3>
                                </td>
                            </tr>
                            <tr class="fp7">
                                <td class="rightline"><h2>NO. OF<br />
                                        PKGS</h2></td>
                                <td class="rightline" colspan="3"><h2>DESCRIPTION OF GOODS</h2></td>
                                <td class="rightline"><h2>HS CODE</h2></td>
                                <td class="rightline" colspan="2"><h2>QTY</h2></td>
                                <td class="rightline" colspan="2"><h2>UNIT VALUE<br />
                                        USD</h2></td>
                                <td><h2>TOTAL<br />
                                        VALUE</h2></td>
                            </tr>
                            <?php if ($this->invoicedetail) {
                                foreach ($this->invoicedetail as $key => $valItem) {
                                    ?>
                                    <tr>
                                        <td align="center"><p><?php echo $valItem->pkgs > 0 ? $valItem->pkgs : ""; ?></p></td>
                                        <td colspan="3" align="center"><p><?php echo $valItem->description; ?></p></td>
                                        <td align="center"><p><?php echo $valItem->hscode; ?></p></td>
                                        <td colspan="2" align="center"><p><?php echo $valItem->num; ?></p></td>
                                        <td colspan="2" align="center"><p><?php echo $valItem->price; ?></p></td>
                                        <td align="center"><p><?php echo $valItem->total; ?></p></td>
                                    </tr>
                           <?php }
                                } ?>
                            <tr class="fp8">
                                <td colspan="9"></td>
                                <td><h2>1TOTAL INVOICE<br />
                                        VALUE</h2></td>
                            </tr>
                            <tr class="fp9">
                                <td colspan="9">&nbsp;</td>
                                <td class="dyg_jg"><p><?php echo $this->invoiceall ? $this->invoiceall->total : 0; ?>(USD)</p></td>
                            </tr>
                            <tr class="fp10">
                                <td colspan="10"><h2>I DECLARE ALL THE INFORMATION CONTAINED IN THE INVOICE TO BE TRUE AND CORRECT.</h2></td>
                            </tr>
                            <tr>
                                <td class="dyg_qm" colspan="4"><h2>SIGNATURE OF SHIPPER / EXPORTER</h2></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td align="center"><h2>DATE</h2></td>
                            </tr>
                            <tr>
                                <td width="70" class="dyg_jg">UUCH</td>
                                <td width="80"></td>
                                <td width="80"></td>
                                <td width="80"></td>
                                <td width="110"></td>
                                <td width="60"></td>
                                <td width="60"></td>
                                <td width="60"></td>
                                <td width="80"></td>
                                <td class="dyg_jg" align="center"><p><?php echo $this->invoiceall ? $this->invoiceall->orderdate : date('Y-m-d'); ?></p></td>
                            </tr>
                        </table>
              <?php }?>
       	  </div>
           <div class="fapiao_cz">
                <input type="hidden" id="billid" name="billid" value="<?php echo $this->billall->billNo;?>" />
                <input type="hidden" id="userid" name="userid" value="<?php echo $this->billall->userId;?>" />
                <input type="hidden" id="ma" name="ma" value="<?php echo $this->ma;?>" />
                <input type="hidden" id="operate" name="operate" value="subinvoice" />
            	<ul>
                    <li><a href="javascript:void(0)" id="savebotton" class="anvbotton"><span>保存</span></a></li>
                    <li><a href="javascript:void(0)" id="printanvbotton" class="anvbotton4"><span>打印</span></a></li>
                    <li><a href="javascript:void(0)" id="printlocalbotton" class="anvbotton4"><span>打印-t</span></a></li>
                    <li><a href="/admini/managewaybill/invoice/id/<?php echo $this->billall->id;?>" id="anvbotton" class="anvbotton4"><span>编辑</span></a></li>
                    <li><a href="javascript:void(0)" id="previewbotton" class="anvbotton4"><span>预览</span></a></li>
                    <li><a href="/admini/managewaybill/preview/download/1/id/<?php echo $this->billall->id;?>" class="anvbotton4" ><span>下载html</span></a></li>
                    <li><a href="/admini/managewaybill/billaccep/id/<?php echo $this->billall->id;?>" class="anvbotton4"><span>返回运单</span></a></li>
                </ul>
            </div>            
        </div>
</form>

            
            <div class="fapiaoright">
            	<div class="qdmcs">
                    <h2>发票填写物品参考 <span style="color:#c00;">(申报价值：<?= $this->billall->getFeeByType(Application_Model_FeeType::ReprotValue) > 0 ? '$' . $this->billall->getFeeByType(Application_Model_FeeType::ReprotValue): '未填写' ?>)</span></h2>
                </div>
                <div class="qdcc">
                    <div class="qdtop">
                        <table>
                            <tr>
                                <th class="qd1">物品编号</th>
                                <th class="qd2">名称</th>
                                <th class="qd3">净重(kg)</th>
                                <th class="qd4">材重(kg)</th>
                            </tr>
                        </table>
                    </div>
                    <?php
                        if($this->storedetail != ''){
                        foreach ($this->storedetail as $Item) {?>
                            <div class="tabletd">
                                <table>
                                        <tr>
                                        <td class="qd1">
                                                <p><?php echo $Item->barcode;?></p>
                                            <span><?php echo date("Y-m-d",strtotime($Item->createdate));?></span>
                                        </td>	
                                        <td class="qd2">
                                            <div class="whpic">
                                                <a href="<?= $this->cdn ?><?= !is_int(strpos('big',$Item->imageFile))?('/big'.$Item->imageFile):($Item->imageFile) ?>"  target="_blank"><img src="<?php echo $this->cdn;?><?php echo $Item->image;?>" /></a>
                                            </div>
                                            <div class="whinfo">
                                                <h2><a href="/admini/managestore/storedetail/id/<?php echo $Item->id;?>"  target="_blank"><?php echo $Item->productName;?></a></h2>
                                                <div class="tez"><?php if(($Item->itemType == 0 || $Item->itemType == "") && $Item->bignessType == 0){}else{?>
                                                    <label>包裹特征：</label>
                                                    <ul class="wupintz"><?php if($Item->itemType != 0){?>
                                                        <li><?php foreach(Application_Model_StoreItem::getNames() as $key=>$value){ 
                                                                if($key != 0 && ($Item->ItemType & $key) == $key){
                                                                    echo "<span>".$value[0]."</span>";
                                                               } } ?></li><?php }?>
                                                        <?php if($Item->bignessType != 0){?>
                                                        <li><span><?php switch ($Item->bignessType) {
                                                            case 0:
                                                                echo "普通";
                                                                break;
                                                            case 1:
                                                                echo "轻抛";
                                                                break;
                                                            case 2:
                                                                echo "抛";
                                                                break;
                                                            case 3:
                                                                echo "重抛";
                                                                break;
                                                            default:
                                                                echo "普通";
                                                                break;
                                                            } ?></span></li><?php }?>
                                                    </ul>
                                                    <?php }?>
                                                </div>
                                            </div>
                                        </td>	
                                        <td class="qd3"><?php echo $Item->weight/1000;?></td>	
                                        <td class="qd4"><?php echo $Item->weight>$Item->volumeWeight?"无":$Item->volumeWeight/1000;?></td>	
                                    </tr>
                                </table>
                                <?php if($Item->remark){?>
                                    <div class="qdbeizhu">
                                            <div class="qdzxb"></div>
                                            <label>清单：</label><?php echo $Item->remark;?>
                                    </div>
                                <?php }?>
                            </div>
                    <?php }}?>
                </div>
            </div>
<script type="text/javascript">
    $("#savebotton").click(function(){
        $("#formshipment").submit();
    });
    $("#previewbotton").click(function(){
        <?php if($this->ma != 1 && $this->ma != 5){ ?>
            $("#operate").val("subpre");
        <?php }else{?>
            $("#operate").val("");
            $("#ma").val(4);
        <?php } ?>
        $("#formshipment").submit();
    });
    $("#printlocalbotton").click(function(){
        $("#operate").val("local");
        $("#formshipment").submit();
    });
    $('#printanvbotton').click(function(){
        <?php if($this->ma != 1 && $this->ma != 5){ ?>
            $("#operate").val("subprin");
        <?php }else{?>
            $("#operate").val("");
            $("#ma").val(3);
        <?php } ?>
        $("#formshipment").submit();
    });
    function prin(i){
        var inna = $("input#inno"+i).val();
        var insu = $("input#insu"+i).val();
        var inpr = $("input#inpr"+i).val();
        var into = $("input#into"+i).val();
        var num = $("input#num").val();
        if(inna != ""  && insu != "" && inpr != "" && into != ""){
            if(i >= num){
                var html = '<tr class="fpxuxian" id="tr'+(i*1+1*1)+'">';
                html+= '<td align="center"><input class="inputwu w30" type="text" id="pkgs'+(i*1+1*1)+'" name="pkgs'+(i*1+1*1)+'" value="" onblur="javascript:prin('+(i*1+1*1)+')"/></td>';
                html+= '<td colspan="3" align="center"><input class="inputwu w200" type="text" name="inna'+(i*1+1*1)+'" id="inna'+(i*1+1*1)+'" value="" onblur="javascript:prin('+(i*1+1*1)+')"/></td>';
                html+= '<td align="center"><input class="inputwu w80" type="text" name="inhs'+(i*1+1*1)+'" id="inhs'+(i*1+1*1)+'" value="" onblur="javascript:prin('+(i*1+1*1)+')" /></td>';
                html+= '<td colspan="2" align="center"><input class="inputwu w30" type="text" name="insu'+(i*1+1*1)+'" id="insu'+(i*1+1*1)+'" value="" onchange="javascript:ckprto('+(i*1+1*1)+')" onblur="javascript:prin('+(i*1+1*1)+')"/></td>';
                html+= '<td colspan="2" align="center"><input class="inputwu w80" type="text" name="inpr'+(i*1+1*1)+'" id="inpr'+(i*1+1*1)+'" value="" onchange="javascript:ckprto('+(i*1+1*1)+')" onblur="javascript:prin('+(i*1+1*1)+')"/></td>';
                html+= '<td align="center"><input class="inputwu w80" type="text" name="into'+(i*1+1*1)+'" id="into'+(i*1+1*1)+'" value="" onchange="javascript:ckprto2('+(i*1+1*1)+')" onblur="javascript:prin('+(i*1+1*1)+')"/></td></tr>';
                $("tr#tr"+i).after(html);
                $("input#num").val((i*1+1*1));
            }
        }
    }
    function ckprto(id){
        var sum = $("input#insu"+id).val();
        var price = $("input#inpr"+id).val();
        var m = 0, s1 = sum.toString(), s2 = price.toString();
        try { m += s1.split(".")[1].length } catch (e) { }
        try { m += s2.split(".")[1].length } catch (e) { }
        var total = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
        $('input#into'+id).val(total);
        var ztotal = 0;
        var num = $("input#num").val();
        for(var i=1;i<(num*1+1*1);i++){
            ztotal = ztotal*1 + $('input#into'+i).val()*1;
        }
        $('input#ztotal').val(ztotal);
    }
    function ckprto2(id){
        var total = $('input#into'+id).val();
        var ztotal = 0;
        var num = $("input#num").val();
        for(var i=1;i<(num*1+1*1);i++){
            ztotal = ztotal*1 + $('input#into'+i).val()*1;
        }
        $('input#ztotal').val(ztotal);
    }
</script>